package com.view
{
	import com.game.Game;
	import com.views.ExampleView;
	
	public class View extends ViewBase
	{
		private var viewObject:Object = new Object();
		private static var _view:View;
		//private static var setValue:Boolean;
		
		public function View()
		{
			if(_view){
				throw Error('不能二次实例化！');
			}else{
				_view = this;
			}
		}
		
		public static function getInstance():View{
			//if(setValue) throw Error('无法访问！');
			//setValue = true;
			if(!_view) _view = new View();
			return _view;
		}
		
		public function get example():ExampleView{
			return createObject(ExampleView) as ExampleView;
		}
		
		private function createObject(className:Class):*
		{
			var key:String = String(className).split('[class ')[1].split(']')[0];
			
			if(viewObject[key]) return viewObject[key];
			
			viewObject[key] = new className();
			
			return viewObject[key];
		}
		
		
		
		
		
		
		
		
		
		
	}
}